let mysql = require('mysql')

var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'hg_userlist'
});
// let sql=`select * from hg_users`
// connection.query(sql, (err, data) => {
//     if (err) {
//         console.log(err);
//     } else {
//         console.log(data);
//     }
// })


function request(sql) {
    return new Promise((resolve,reject) => {
        connection.query(sql, (err, data) => {
            if (err) {
                reject(err)
            } else {
                resolve(data)
            }
        })
    })
}

module.exports = {
    connection,
    request
}